package com.myacg.editor.common.unit.panel.taskpanel;

import com.myacg.core.task.KeepTask;
import com.myacg.editor.common.entity.CoupleDao;
import com.myacg.editor.common.unit.list.item.FlowListItem;
/**
 * 继承此接口的任务可以拥有对应的UI展示页面
 * @author Administrator
 *
 */
public abstract class UIKeepTask extends KeepTask{
	private KeepTaskManagerPanel parent;
	private String taskName;
	private int executeCount;
	public UIKeepTask(long howSecond) {
		super(howSecond);
	}
	@Override
	public void secondExecute() {
		++executeCount;
		//获得对应的item , 通知刷新UI 
		if(this.parent!= null){
			FlowListItem<CoupleDao> item = this.parent.getTaskList().getItem(this.getId());
			if(item != null){
		 		item.getData().setValue(executeCount+"次");
		 		item.repaint();
			}
		} 
		execute();
	}  
	@Override
	public void overExecute() {
		//删除UI
		if(this.parent!=null){
			this.parent.getTaskList().removeItem(this.getId());
		}
		overTask();
	};
	public abstract  void execute();
	public abstract  void overTask();

	public KeepTaskManagerPanel getParent() {
		return parent;
	}

	public void setParent(KeepTaskManagerPanel parent) {
		this.parent = parent;
	}

	public int getExecuteCount() {
		return executeCount;
	}

	public void setExecuteCount(int executeCount) {
		this.executeCount = executeCount;
	}
	public String getTaskName() {
		return taskName;
	}
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}
	
}
